<template>
  <div class="box">
    <div
      class="goods"
      @click="goodsClick"
      v-for="(good, index) in goods"
      :key="index"
    >
      <img :src="good.img" alt="" />
      <p class="info">{{ good.title }}</p>
      <div class="count">
        <div class="countl">
          <b>{{ good.price | showPrice }}</b>
          <span>{{ good.lprice | showPrice }}</span>
        </div>
        <span class="iconfont icon-sangedian"></span>
      </div>
    </div>
    <!-- <div class="ccar" @click="goCar">
      <van-icon name="shopping-cart" badge="1" />
    </div> -->
  </div>
</template>

<script>
import { getYohoGoods } from "network/home";
export default {
  name: "",
  data() {
    return {
      path: "/goodsdetails",
      goods: [],
    };
  },
  created() {
    getYohoGoods().then((res) => {
      this.goods = res;
    });
  },
  methods: {
    goodsClick() {
      console.log("goodsClick");
      this.$router.push(this.path);
    },
    // goCar() {
    //   this.$router.push("/shoppingcar");
    // },
  },
  filters: {
    showPrice(price) {
      return "￥" + price.toFixed(2);
    },
  },
};
</script>
<style scoped>
@import url(../../assets/font/iconfont);
.box {
  width: 348px;
  margin: auto;
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.goods {
  /* border: 1px solid red; */
  width: 162px;
  margin-bottom: 20px;
  min-height: 279px;
}
.goods img {
  width: 100%;
  height: 218px;
}
.info {
  font-size: 10px;
  height: 30px;
  margin: 10px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: grey;
}
.count {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.countl {
  width: 60px;
  display: flex;
  margin-bottom: 3px;
  font-size: 11px;
  align-items: center;
  justify-content: space-between;
}
.vip {
  width: 30px;
  height: 14px;
  text-align: center;
  line-height: 14px;
  font-size: 4px;
  margin-left: 3px;
  color: #ad8a36;
  background-color: #fbebb7;
  border-radius: 30px;
}
.countl b {
  color: red;
  margin-right: 5px;
}
.countl span {
  color: grey;
  text-decoration: line-through;
}
b {
  color: grey;
  font-weight: 900;
}
.ccar {
  width: 40px;
  height: 40px;
  opacity: 0.7;
  line-height: 50px;
  text-align: center;
  font-size: 25px;
  color: aliceblue;
  background-color: black;
  border-radius: 50%;
  position: fixed;
  right: 20px;
}
</style>